package com.tan.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

@Configuration
@PropertySource("classpath:db.properties")
public class MyConfig3 {
    @Bean
    public DataSource dataSource(@Value("${mysql.driverClass}") String driverClassName,
                                 @Value("${mysql.url}") String url,
                                 @Value("${mysql.user}") String username,
                                 @Value("${mysql.password}") String password){
        DruidDataSource dataSource=new DruidDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}
